home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: news.ifm.liu.se!liuida!news
- From: c92manen@und.ida.liu.se (Mans Engman)
- Subject: Re: Sorting a list
- X-Nntp-Posting-Host: astmatix.ida.liu.se
- Message-ID: <1958.6657T325T1880@und.ida.liu.se>
- Sender: news@ida.liu.se
- Organization: CIS Dept, Linkoping University, Sweden
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP) *UNREGISTERED*
- References: <272.6650T63T1340@sn.no> <ZZNYYD.96Mar21121908@diku.dk> <xUqu7MD1A7alz7@0dietmar.tomate.tng.oche.de>
- Date: Sun, 24 Mar 1996 04:25:37 GMT
-
-
- >You could use a simple modification of bubble sort to boost performance to
- >the speed of QuickSort: use a dynamic interval instead of comparing
- >neighbours only. In the first pass, you would compare element <a> to
- >element <a + distance> and swap them if the order is wrong. Distance is
- >reduced after processing all elements. To be continued until the distance
- >is <1> (standard bubble sort) and the order is correct.
-
- This "modified bubble sort" is actually a special case of an algorithm
- called shell sort. It's a very interesting algorithm, for more than one
- reason: It's easy to implement, with very little overhead. It's fast. It's
- completely impossible to analyse! :)
-
- Some comments: The algorithm for sorting the "slices" of elements should be
- one that will sort an almost-sorted or completetly sorted sequence very fast.
- So bubble sort is actually a much better choice than quicksort :)
- However insertion sort is usually a little bit better in this case.
- Then there's the question of how many passes the algorithm should do, and what
- "distances" should be used. This may be fine-tuned for optimal performance on
- a certain number of elements, and the overhead of the implementation.
- For instance, a usually nice sequence of distances is 1, 3, 7, 15, 31...
- This results in O(n^1.5) time complexity (worst-case).
-
- But completely OTOH since we were really talking strings and not algorithm
- theory, I'd suggest either a radix sort or combined bin+quick sort...
-
- >* In a random sampling of GoldED users, 100% said that they'd rather use
- > GoldED than be publically flogged, eaten alive by pirhanas, OR watch
- > SeaQuest DSV.
-
- Hmmm!!
- This sounds a bit like Macintosh marketing, doesn't it? :)
-
- >/\/\ GoldED Support: http://www.clearlight.com/~dietmar
- >/\/\ E-Mail: dietmar@tomate.tng.oche.de
- >/\/\ Fileserver: dietmar@clearlight.com (subject: send file info)
- > Phone/FAX: +49-(0)241-81665-(Pause)-22
-
-
- /Mans (.sig being recompiled)
-
-